#include <vector>
#include <deque>
#include <iostream>
#include <algorithm>

using namespace std;

int main( int argc, char *argv [] )
{
	vector< int > v;
	for( int i = 0 ; i < 10; i++ )
		v.push_back( i );

	for_each( v.begin(), v.end(), [](int n){ cout << n << ' '; } );
	cout << endl;

	deque < int > d;
	transform( v.begin(), v.end(), front_inserter( d ), [](int n) { return n * n; } );
	for_each( d.begin(), d.end(), []( int n ){ cout << n <<  ' '; } );
	cout << endl;

	// transform( v.begin(), v.end(), front_inserter( d ), [](int n) {
	transform( v.begin(), v.end(), front_inserter( d ), [](int n)->int {
			if( n % 2 == 0 )
				return n * 1.5;
			else 
				return n * n;
			} );
	for_each( d.begin(), d.end(), []( int n ){ cout << n <<  ' '; } );
	cout << endl;

	cout << "------------------------------------------------" << endl;

	int x = 100, y = 200;
	// for_each( v.begin(), v.end(), [x, y](int n )mutable{ cout << n + x++ + y++ << ' ' ;} );
	for_each( v.begin(), v.end(), [=](int n )mutable{ cout << n + x++ + y++ << ' ' ;} );
	cout << endl;
	cout  << x << " " << y << " " << endl;
	// for_each( v.begin(), v.end(), [&x, &y](int n ){ cout << n + x++ + y++ << ' ' ;} );
	for_each( v.begin(), v.end(), [&](int n ){ cout << n + x++ + y++ << ' ' ;} );
	cout << endl;
	cout  << x << " " << y << " " << endl;

	return 0;
}

